//
//  HomeWebSiteViewController.m
//  BaoVn
//
//  Created by Le Anh Tai on 11/6/14.
//  Copyright (c) 2014 Le Anh Tai. All rights reserved.
//

#import "HomeWebSiteViewController.h"
#import "WebsiteViewController.h"


@interface HomeWebSiteViewController ()

@end

@implementation HomeWebSiteViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    _flipView = [[HomeWebsiteFlipView alloc] init];
    _flipView.delegate = self;
    [_contentView addSubview:_flipView];
    
    _toolbarView = [[ToolbarHomeWebsiteView alloc] init];
    _toolbarView.delegate = self;
    _toolbarView.frame = RECT(0, 0, 92, 44);
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:_toolbarView];
    
    _menuView = [[MenuHomeWebsiteView alloc] init];
    _menuView.delegate = self;
    [self.navigationController.view addSubview:_menuView];

    //dummy
    _toolbarView.badgeButton.badge = 90;
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
}

- (void)viewWillLayoutSubviews
{
    [super viewWillLayoutSubviews];
    
    _flipView.frame = _contentView.bounds;
    _menuView.frame = self.view.bounds;
}

#pragma mark - Delegate
- (void)toolbarHomeWebsiteDidPressMenuButton:(ToolbarHomeWebsiteView *)toolbar
{
    [_menuView animateShowMenu];
}

- (void)toolbarHomeWebsiteDidPressBadgeButton:(ToolbarHomeWebsiteView *)toolbar
{
    
}

#pragma mark - 
- (void)menuHomeWebsiteDidPressListNewsItem:(MenuHomeWebsiteView *)view
{
    [AppInfo shared].newsType = NewsTypeItem;
    
    [_flipView switchToNewsType:[AppInfo shared].newsType];
}

- (void)menuHomeWebsiteDidPressCardNewsItem:(MenuHomeWebsiteView *)view
{
    [AppInfo shared].newsType = NewsTypeCard;
    
    [_flipView switchToNewsType:[AppInfo shared].newsType];
}

#pragma mark -
- (void)flipView:(BaseFlipView *)view didSelectData:(NSDictionary *)data
{
    WebsiteViewController *controller = [[WebsiteViewController alloc] init];
    [self pushController:controller animated:YES];
}

@end
